﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _028接口_依赖反转_单元测试_2实现接口
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //低耦合  
            var user = new PhoneUser(new EricssonIPhone());
            user.UsePhone();
        }
    }

    interface IPhone
    {
        void Dail();
        void PickUp();
        void Send();
        void Receive();
    }

    class NokiaPhone : IPhone
    {
        void IPhone.Dail()
        {
            Console.WriteLine("Nokia calling ...");
        }

        void IPhone.PickUp()
        {
            Console.WriteLine("Hello! This is Tim !");
        }

        void IPhone.Receive()
        {
            Console.WriteLine("Nokia message ring ...");
        }

        void IPhone.Send()
        {
            Console.WriteLine("Hello!");
        }
    }

    class EricssonIPhone : IPhone
    {
        public void Dail()
        {
            Console.WriteLine("Ericsson calling");
        }

        public void PickUp()
        {
            Console.WriteLine("Hi,This's Tim!");
        }

        public void Receive()
        {
            Console.WriteLine("This's Meaages");
        }

        public void Send()
        {
            Console.WriteLine("I'will Send");
        }
    }


    class PhoneUser
    {
        private IPhone _phone;
        public PhoneUser(IPhone phone)
        {
            this._phone = phone;
        }

        public void UsePhone()
        {
            _phone.Dail();
            _phone.PickUp();
            _phone.Receive();
            _phone.Send();
        }
    }
}
